package utility;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;

public class Database {
	protected Connection con;
	private final static String DRIVER="com.mysql.jdbc.Driver";
	private final static String URL="jdbc:mysql://localhost/football_management";
	private final static String USER_NAME="root";
	private final static String PASSWORD="";
	public Database() {
		//this.connect();
	}
	
	public void close(){
		if(con!=null){
			try {
				con.close();
				con=null;
			} catch (SQLException e) {
				Log.write(e);
			}
		}else{
			con=null;
		}
		
	}
	/**
	 * 
	 */
	public void connect(){
		try {
			Class.forName(DRIVER);
			con = DriverManager.getConnection(URL, USER_NAME, PASSWORD);
			System.out.println("connection success.");
		} catch (Exception e) {
			Log.write(e);
		} 
	}

	public static void main(String[] args) {
		new Database();
	}
}
